package xyz.showbooks.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.dfm.pojo.RightsPojo;
import xyz.dfm.util.JsonResult;
import xyz.dfm.util.WebUtil;
import xyz.dfm.vo.PageResult;
import xyz.showbooks.service.RightsService;

import java.util.List;


/**
 * @author: Dsi
 * @date: 2022/2/17 15:44
 * @description:
 */
@RestController
@CrossOrigin
public class RightsController {
    @Autowired
    private RightsService rightsService;
    //获取右侧菜单
    @GetMapping("/rights/getRightsList")
    public JsonResult<List<RightsPojo>> getRightsList(){
        List<RightsService> rightsList = rightsService.getRightsList();
        return JsonResult.build().code(200)
                .data(rightsList);
    }
    //通过name查找菜单
    @GetMapping("/menu/findMenuByName/{menuName}")
    public JsonResult<List<RightsPojo>> findMenuByName(PageResult pageResult){
        if(WebUtil.stringIsNull(pageResult.getQuery())){return JsonResult.build(201, "参数错误");}
        return JsonResult.build().code(200).data(rightsService.findMenuByName(pageResult));
    }
}
